<?php
	$protectid="305"; 
	include("../protect.php");
	
	include_once("../../config.inc.php");
	
	include_once(CFG_LIB_DIR.'mysqldb.inc.php');
	$objDb = new mysqldb();
	
	include_once(CFG_LIB_DIR."block.php");
	$Block = new clsBlock();
	
	include_once(CFG_LIB_DIR."generic.lib.php");
	$objBase = new clsBase();
	
	include(CFG_LIB_DIR."buy_car_cs.php");
	$objBuyCar = new Buy_CS();
	
	include_once(CFG_LIB_DIR."manage_page.php");	
	$objManPage = new clsManagePage();
	$ProductID = $_GET['id'];
	
	
	//分页获取数据
	//$OrderResult = $objManPage->GetResult('t1.*,t2.MemberName', '`'.con_strPREFIX.'buyorder` t1 inner join `hy_b_member` t2 on t1.UID=t2.MemberID ', ' ORDER BY t1.ID DESC', 20, true);
	
if($action == 'search'){
	if($keywords){  $con .= " and orderNum like '%$keywords%'"; }
	if($startDate && $endDate) {
	   $startDate = strtotime($startDate);
	   $endDate = strtotime($endDate);
	   $con .= " and createdate between $startDate  and  $endDate ";
	} 
	if($member){
	    $con .= " and memberID in (select user_id from hy_member where user_name like  '%".$member."%')";
	}
	if($shop){
	    $con .= " and memberID in (select user_id from hy_member where user_shopname like  '%".$shop."%')";
	}
	if($s_county){
	    $con .= " and memberID in (select user_id from hy_member where s_county =".$s_county." )";
	}
	if($s_city){
		$con .= " and memberID in (select user_id from hy_member where s_city =".$s_city." )";
	}
	if($state){
		$con .= " and state =".$state." ";
	}
	
	//echo $con;die;
	
} else {
	if($id){
	   $con .= " and  memberID = $id ";
	}
}
	
$OrderResult = $objManPage->GetResult('*', '`hy_b_order` ', $con.'  ORDER BY  ID DESC', 20, true);



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrator's Control Panel</title>
<script type="text/javascript">
<!--
function showcontent(imgdom,s){
	var dom=document.getElementById("contenttr"+s);
	if(dom.style.display=="none"){
		dom.style.display="";
		imgdom.src="logo.jpg";
	}
	else{
		dom.style.display="none";
		imgdom.src="logo2.jpg";
	}
}
function setselall(s){
	var dom=document.getElementsByName("sel[]");
	var domflag=false;
	if(s==true){domflag=true;}
	for(i=0;i<dom.length;i++){
		dom[i].checked=domflag;
	}
}

function checkchoose(){
	var dom=document.getElementsByName("sel[]");
	var num=0;
	for(i=0;i<dom.length;i++){
		if(dom[i].checked==true){
			num +=1;
			break;
		}
	}
	if(num==0){
		alert('请选择要进行操作的记录');
		return false;
	}
	else{
		return true;
	}
}
-->
</script>
<?php include_once("../common/files.php"); ?>
<script type="text/javascript" src="../js/jquery-1.2.6.min.js"></script>
</head>
<body id="main" >
<div >
  <form name="form1" method="get" action="">
    <input name="action" type="hidden" value="search">
    <table width="100%" class="listtable">
          <tr>
        <td width="15%" height="24" nowrap><span class="style1">订单号:</span>&nbsp;&nbsp;</td>
        <td>
          <input name="keywords" type="text"  size="20" value="<?=$keywords?>"></td>
      </tr>
       <tr>
        <td height="24" nowrap><span class="style1">会员:</span>&nbsp;&nbsp;</td>
        <td>
          <input name="member" type="text"  size="20" value="<?=$member?>"></td>
      </tr>
      
        <tr>
        <td height="24" nowrap><span class="style1">网店:</span>&nbsp;&nbsp;</td>
        <td>
          <input name="shop" type="text"  size="20" value="<?=$shop?>"></td>
      </tr>
         <tr>
        <td height="24" nowrap><span class="style1">订单状态:</span>&nbsp;&nbsp;</td>
        <td>
          <select name="state">
            <option value="">请选择</option>
            <? if($arrOrderState){
			 foreach($arrOrderState as $key=>$value){
			?>
            <option value="<?=$key?>"><?=$value?></option>
            <? }} ?>
            
          </select>
          </td>
      </tr>
       <tr>
        <td height="24" nowrap><span class="style1">县份、区域:</span>&nbsp;&nbsp;</td>
        <td>
               
   <select name="s_city" id="s_city">
           <option value=''>
	       请选择
	      </option>
		    <?php	
		$SQL=" select * from hy_b_city where ParentID =116  ";
		$objDb->query($SQL);
		$result = $objDb->get_data();
		if($result){
		foreach($result as $key=>$value){
	 ?>
		    <option value="<?=$value['CityID']?>" >
		      <?=$value['CateName']?>
	        </option>
		    <? }}?>
	      </select>
		   <select name="s_county" id="s_county">
	    
	    <option value=''>
	       请选择
	      </option>
	    
      </select>
           <script>
          
$('#s_city').change( function () { 
		$.ajax({
		   type: "get",
		   url: "../../selectcity.php",
		   data: "pid="+this.value,
		   success: function(msg){
			  // alert(msg);
			    $('#s_county').html(msg);
		   }
		});
});


          </script>
          
          </td>
      </tr>
      
      
      <tr>
        <td><label> 下单时间：</label></td>
        <td>
            <input type="text" name="startDate" id="startDate" size="10" value="" />
            <span>*</span> <img src="../js/jscalendar/img.gif" id="f_trigger_c2"
           style="cursor: pointer; border: 1px solid red;"
           title="Date selector"
           onMouseOver="this.style.background='red';"
           onMouseOut="this.style.background=''" /> 
            <script type="text/javascript">
          Calendar.setup({
              inputField     :    "startDate",
              ifFormat       :    "%Y-%m-%d",
              button         :    "f_trigger_c2",
              align          :    "Tl",
              singleClick    :    false
          });
              </script> 
            -
            <input type="text" name="endDate" id="endDate" size="10" value="" />
            <span>*</span> <img src="../js/jscalendar/img.gif" id="f_trigger_c2"
           style="cursor: pointer; border: 1px solid red;"
           title="Date selector"
           onMouseOver="this.style.background='red';"
           onMouseOut="this.style.background=''" /> 
            <script type="text/javascript">
          Calendar.setup({
              inputField     :    "endDate",
              ifFormat       :    "%Y-%m-%d",
              button         :    "f_trigger_c1",
              align          :    "Tl",
              singleClick    :    false
          });
      </script> 
          </td>
      </tr>
      <tr>
        <td width="13%" colspan="2"><input type="submit" name="Submit2" value="搜索"></td>
      </tr>
    </table>
  </form>
</div>
<br/>
<form name="form1" method="post" action="order_del.php" onsubmit="return checkchoose();">
  <input name="action" id="action" type="hidden" value="del" />
  <table summary="" id="pagehead" cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
      <td><h1>查看订单</h1></td>
    </tr>
  </table>
  <table cellspacing="0" cellpadding="0" width="100%"  class="listtable">
    <tr bgcolor="#F3F7FF">
      <th width="9%"><input name="selAll" type="checkbox" value="" onclick="setselall(this.checked)" />
        全选</th>
      <th width="8%">查看明细</th>
      <th width="23%" >订单号</th>
      <th width="12%">订购者</th>
      <th width="15%">状态</th>
      <th width="20%" >订购时间</th>
      <!--<th width="10%">操作</th>--> 
    </tr>
    <?php
	//输出 Manage Grid
	if(is_array($OrderResult))
	{
		foreach($OrderResult as $key => $Order)
		{
			  $totaoprice[] = $Order['TotalPrice'];
?>
    <tr>
      <td align="center" valign="middle"><input name="sel[]" id="sel[]" type="checkbox" value="<?=$Order['id']?>" /></td>
      <td align="center"><img src="logo2.jpg"  style="cursor:hand;" onclick="javascript:showcontent(this,'<?=$Order['id']?>')" /></td>
      <td align="center"><?php echo $Order['orderNum'];?></td>
      <td align="center"><?
	  $SQLX="select * from hy_member  where user_id='".$Order['memberID']."' ";
								//echo $SQL;
								$objDb->query($SQLX);
								$rssX=$objDb->get_data();
								echo $rssX[0]['user_name'];
								?></td>
      <td align="center"><?php echo $arrOrderState[$Order["state"]];?></td>
      <td align="center"><?php echo date("Y/m/d H:i:s",$Order['createdate']);?></td>
      <!--<td align="center"><a href="order_del.php?id=<? echo $Order['id'];?>&action=del" onClick="return confirm('你确定要删除吗？')" >删除</a></td>--> 
    </tr>
    <tr id="contenttr<?=$Order['id']?>" style="display:none;">
      <td align="center" bgcolor="#F3F3F3">明细</td>
      <td colspan="9" align="left"><div >
          <div id="order_div">
            <?php
			
			//$price=$price.;
			
			echo "<table cellspacing='0' cellpadding='0' border=1 bordercolor=\"#F3ECCD\" width='100%'  >";
            
			echo "<tr align='left'>";
            echo "<td width='10%' align=\"left\">产品明细：</td><td align=\"left\">";
				//获取订单产品明细
			$productNames=explode(",",$Order['productName']);
			$prices=explode(",",$Order['price5']);
			$buyNums=explode(",",$Order['buyNum']);
			$Floors=explode(",",$Order['Floor']);
			$Dates=explode(",",$Order['Date']);
			$Times=explode(",",$Order['Time']);
			$ZheKous=explode(",",$Order['ZheKou']);
			$productID=explode(",",$Order['productID']);
			//$TotalPrices=explode(",",$Order['TotalPrice']);
			//var_dump($productNames);
			$geshu=sizeof($productNames);
				if($geshu)
			{
				echo "<table cellspacing='0' cellpadding='0' border=1 bordercolor=\"#F3ECCD\" width='100%'  >
						  <tr  bgcolor=\"#F3F3F3\">
						 
							<td width='30%'>产品名称</td>
						
							<td width='10%'>定金(￥)</td>
							
							<td width='10%'>数量</td>
							 <td width='30%'>操作</td>
							
						  </tr>";
				for($i=0;$i<$geshu;$i++){
					
					echo "
						  <tr>
							
					<td>".$productNames[$i]."</A></td>
							<td>￥".$prices[$i]."</td>
							
							<td>".$buyNums[$i]."</td>
						<td><A href='../product/product.php?act=modify&id=".$productID[$i]."' target='_blank' >查看所有号码？</A></td>
						  </tr>
					";
				}
				echo "<tr><td  colspan=\"3\">合计:</td><td>￥".$Order['TotalPrice5']."元</td></tr></table>";
				
			}
			echo "</td>";
			echo "</tr>";

			echo "
			<tr>";
			
			$totalprice=$t_price*$t_buynum*$t_zhekou*0.1;
			
			
	
			echo "<tr>";
			echo "<td>收货人姓名：</td><td>".$Order['PersonName']."</td>";
			echo "</tr>";
			
			echo "<tr>";
			echo "<td>电子邮件地址：</td><td>".$Order['Email']."</td>";
			echo "</tr>";
			
			echo "<tr>";
			echo "<td>详细地址：</td><td>".$Order['Address']."</td>";
			echo "</tr>";
			
			echo "<tr>";
			echo "<td>邮政编码：</td><td>".$Order['PostCode']."</td>";
			echo "</tr>";
			
			   echo "<tr>";
			echo "<td>电话：</td><td>".$Order['Telephoto']."</td>";
			echo "</tr>";
			
			   echo "<tr>";
			echo "<td>手机：</td><td>".$Order['Mobile']."</td>";
			echo "</tr>";
			
			   echo "<tr>";
			echo "<td>最佳送货时间：</td><td>".$Order['SendTime']."</td>";
			echo "</tr>";
			
			
		
			
			
			echo "</table>";
            ?>
          </div>
        </div></td>
    </tr>
    <?php	
		}
	}
?>
  </table>
  <br />
  <div>
合计充值金额： <?php echo @array_sum($totaoprice);?>
</div>
  <div style="text-align:left;">
    <input name="submit" type="submit" value="删除" />
    &nbsp;&nbsp;&nbsp;&nbsp;
<input name="submit2" type="submit" value="处理中" onclick="document.getElementById('action').value='3';" />
    &nbsp;
    <input name="submit2" type="submit" value="已发货" onclick="document.getElementById('action').value='4';" />
  &nbsp;&nbsp;</div>
  <?php	
	//输出分页
	echo $objManPage->ShowLink();
?>
</form>
<?php include "../bottom.php"; ?>
</body>
</html>
